#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 10;
//const int MAXL = 1e6 + 10;

struct Node
{
    int d;
    int v0;
    int a;
}cars[MAXN];

struct Node2
{
    int times = 0;
    map<int,int> crs;
}need[MAXN];

int dets[MAXN];

inline int read()
{
	int x = 0,f = 1;
	char ch = getchar();

	while(ch < '0' || ch > '9')
	{
		if(ch == '-')
		{
			f = -1;
		}
		ch = getchar();
	}

	while(ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}

	return x * f;
}

void check(int n,int m,int L,int V)
{
    int cnt = 0;
    for(int i = 0;i < n;i++)
    {
        if(cars[i].a == 0)
        {
            if(cars[i].v0 <= V)
            {
                continue;
            }

            if(cars[i].d <= dets[m - 1])
            {
                cnt++;
                for(int j = 0;j < m;j++)
                {
                    if(dets[j] >= cars[i].d && dets[j] <= L)
                    {
                        need[j].times++;
                        need[j].crs[need[j].times - 1] = i;
                    }
                }
            }
        }
        else if(cars[i].a < 0)
        {
            if(cars[i].v0 < 3)
            {
                continue;
            }

            int flg = 0;
            double pos = cars[i].d + (9 - pow(cars[i].v0,2)) / 2 / cars[i].a;

            for(int k = cars[i].d;k < pos;k++)
            {
                for(int j = 0;j < m;j++)
                {
                    if(k == dets[j])
                    {
                        need[j].times++;
                        need[j].crs[need[j].times - 1] = i;
                        if(flg)
                        {
                            continue;
                        }
                        cnt++;
                        flg = 1;
                    }
                }
            }
        }
        else
        {
            if(cars[i].v0 > 3)
            {
                if(cars[i].d <= dets[m - 1])
                {
                    cnt++;
                    for(int j = 0;j < m;j++)
                    {
                        if(dets[j] >= cars[i].d && dets[j] <= L)
                        {
                            need[j].times++;
                            need[j].crs[need[j].times - 1] = i;
                        }
                    }
                }
            }
            double pos = cars[i].d + (9 - pow(cars[i].v0,2)) / 2 / cars[i].a;
            if(pos <= dets[m - 1])
            {
                cnt++;
                for(int j = 0;j < m;j++)
                {
                    if(dets[j] > pos && dets[j] <= L)
                    {
                        need[j].times++;
                        need[j].crs[need[j].times - 1] = i;
                    }
                }
            }
        }
    }

    printf("%d",cnt);
    cout << ' ';

    int res = 0;
    while(true)
    {
        int flg = 0;
        for(int i = 0;i < m;i++)
        {
            if(need[i].times)
            {
                flg = 1;
            }
        }

        if(flg == 0)
        {
            printf("%d",n - res + 2);
            break;
        }

        int ndmax = -1,f = -1;
        for(int i = 0;i < m;i++)
        {
            if(ndmax < need[i].times)
            {
                ndmax = need[i].times;
                f = i;
            }
        }

        res++;
        for(int j = 0;j < m;j++)
        {
            if(j == f)
            {
                continue;
            }

            if(need[j].times == 0)
            {
                continue;
            }

            for(int i = 0;i < need[f].times;i++)
            {
                if(need[j].crs.find(need[f].crs[i]) != need[j].crs.end())
                {
                    need[j].crs.erase(need[j].crs.find(need[f].crs[i]));
                    need[j].times--;
                }
            }
        }
        need[f].crs.clear();
        need[f].times = 0;
    }
    return;
}

int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);

	int T = 0;
	T = read();

	for(int i = 0;i < T;i++)
    {
        int n = 0,m = 0,L = 0,V = 0;
        n = read();
        m = read();
        L = read();
        V = read();

        for(int j = 0;j < n;j++)
        {
            cars[j].d = read();
            cars[j].v0 = read();
            cars[j].a = read();
        }

        for(int j = 0;j < m;j++)
        {
            cin >> dets[j];
        }

        sort(dets,dets + m);
        check(n,m,L,V);
    }


	fclose(stdin);
	fclose(stdout);

	return 0;
}
